﻿//
// Decompiled with: Decompiler.NET, Version=1.3.1.18439, Culture=neutral, PublicKeyToken=null, Version: 1.3.1.18439
// Decompilation Started at: 3/15/2009 10:34:26 PM
// Copyright 2003 - 2004, Jungle Creatures, Inc., All Rights Reserved. 
// Written by Jonathan Pierce, Email: support@junglecreatures.com
//

namespace PatientManagement

{
		
		#region Namespace Import Declarations
		
			using System.ComponentModel;
			using System.Data.SqlClient;
			using System.Drawing;
			using System;
			using System.Resources;
			using System.Windows.Forms;
			
		#endregion
		
	public class frmThemNguoiTruyNhap : Form
	
	{
		
		#region Fields
			private Button btThem;
			private Button btThoat;
			private ComboBox cbRole;
			private Container components;
			private string connStr;
			public int flag;
			private Label label1;
			private Label label2;
			private Label label3;
			private Label label4;
			private Label label5;
			private TextBox tbPassword;
			private TextBox tbPasswordConfirm;
			private TextBox tbUserName;
		#endregion
		
		#region Constructors
		
			public frmThemNguoiTruyNhap ()
			
			{
				this.components = ((System.ComponentModel.Container) null);
				this.flag = 1;
				this.InitializeComponent ();
				this.connStr = Connection.ConnectionString ();
				return;
			}
			
		#endregion
		
		#region Methods
		
			private void btThem_Click (object sender, EventArgs e)
			
			{
				int i;
				int i2;
				string theString;
				SqlConnection theSqlConnection;
				SqlCommand theSqlCommand;
				SqlDataReader theSqlDataReader;
				Class theClass;
				string theString2;
				string theString3;
				SqlCommand theSqlCommand2;
				Exception theException;
				object[] theObjectArray;
				if (this.tbUserName.Text != "")
				{
					goto L_002F;
				}
                DialogResult theDialogResult = MessageBox.Show("Vui lòng nhập tên Truy Nhập!", "Lỗi nhập", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_02DE;
				
			L_002F:
				
				{
				}
				if (this.tbPassword.Text != "")
				{
					goto L_005E;
				}
                DialogResult theDialogResult2 = MessageBox.Show("Vui lòng nhập Nhập Mật Khẩu!", "Lỗi nhập", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_02DE;
				
			L_005E:
				
				{
				}
				if (this.tbPasswordConfirm.Text != "")
				{
					goto L_008D;
				}
                DialogResult theDialogResult3 = MessageBox.Show("Vui lòng nhập Xác Nhận Mật Khẩu!", "Lỗi nhập", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_02DE;
				
			L_008D:
				
				{
				}
				if (this.tbPassword.Text.ToString () == this.tbPasswordConfirm.Text.ToString ())
				{
					goto L_00CC;
				}
                DialogResult theDialogResult4 = MessageBox.Show("Mật khẩu không đối xứng!", "Lỗi nhập", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_02DE;
				
			L_00CC:
				
				{
				}
				if (this.cbRole.Text != "")
				{
					goto L_00FB;
				}
                DialogResult theDialogResult5 = MessageBox.Show("Vui lòng chọn quyền truy nhập!", "Lỗi nhập", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_02DE;
				
			L_00FB:
				
				{
				}
				i2 = 0;
                if (!this.cbRole.Text.Equals("Trưởng Phòng Khám"))
				{
					goto L_0118;
				}
				i = 0;
				goto L_0150;
				
			L_0118:
				
				{
				}
                if (!this.cbRole.Text.Equals("Bác Sĩ"))
				{
					goto L_0133;
				}
				i = 1;
				goto L_0150;
				
			L_0133:
				
				{
				}
				if (! this.cbRole.Text.Equals ("Y Tá"))
				{
					goto L_014E;
				}
				i = 2;
				goto L_0150;
				
			L_014E:
				
				{
				}
				i = 3;
				
			L_0150:
				
				{
				}
				theString = string.Concat ("SELECT * FROM Users WHERE usrName=\'", this.tbUserName.Text, "\'");
				theSqlConnection = new SqlConnection (this.connStr);
				theSqlCommand = new SqlCommand (theString, theSqlConnection);
				theSqlCommand.Connection.Open ();
				theSqlDataReader = theSqlCommand.ExecuteReader ();
				goto L_019B;
				
			L_0197:
				
				{
				}
				i2++;
				
			L_019B:
				
				{
				}
				if (theSqlDataReader.Read ())
				{
					goto L_0197;
				}
				theSqlCommand.Connection.Close ();
				if (i2 <= 0)
				{
					goto L_01E1;
				}
                DialogResult theDialogResult6 = MessageBox.Show(string.Concat("Tên truy nhập: \'", this.tbUserName.Text, "\' đã tồn tại.\n Vui lòng chọn tên truy nhập khác?"), "Tên truy nhập đã tồn tại!", MessageBoxButtons.OK, MessageBoxIcon.Hand);
				goto L_02DE;
				
			L_01E1:
				
				{
				}
				theClass = new Class ();
				theString2 = this.tbPassword.Text.ToString ();
				theString2 = theClass.Encrypt (theString2);
				theObjectArray = new object[7];
				theObjectArray[0] = "INSERT INTO Users VALUES(\'";
				theObjectArray[1] = this.tbUserName.Text.ToString ();
				theObjectArray[2] = "\', \'";
				theObjectArray[3] = theString2;
				theObjectArray[4] = "\', ";
				theObjectArray[5] = i;
				theObjectArray[6] = ")";
				theString3 = string.Concat (theObjectArray);
				
			L_025E:
				try
				{
					theSqlCommand2 = new SqlCommand (theString3, theSqlConnection);
					theSqlCommand2.Connection.Open ();
					int i3 = theSqlCommand2.ExecuteNonQuery ();
					theSqlCommand2.Connection.Close ();
					DialogResult theDialogResult7 = MessageBox.Show ("Thêm mới thành công!", "Thêm mới thành công!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
					this.tbUserName.Text = "";
					this.tbPassword.Text = "";
					this.tbPasswordConfirm.Text = "";
				}
				catch (Exception theException2)
				{
					
				L_02CD:
					theException = theException2;
					DialogResult theDialogResult8 = MessageBox.Show (theException.Message);
				}
				
			L_02DE:
				return;
			}
			
			private void btThoat_Click (object sender, EventArgs e)
			
			{
				base.Close ();
				return;
			}
			
			protected override void Dispose (bool disposing)
			
			{
				this.flag = 0;
				if (! disposing)
				{
					goto L_001D;
				}
				if (this.components == null)
				{
					goto L_001D;
				}
				this.components.Dispose ();
				
			L_001D:
				
				{
				}
				base.Dispose (disposing);
				return;
			}
			
			private void frmThemNguoiTruyNhap_Load (object sender, EventArgs e)
			
			{
				return;
			}
			
			private void InitializeComponent ()
			
			{
				ResourceManager theResourceManager;
				object[] theObjectArray;
				Control[] theControlArray;
				theResourceManager = new ResourceManager (typeof (frmThemNguoiTruyNhap));
				this.label1 = new Label ();
				this.label2 = new Label ();
				this.label3 = new Label ();
				this.label4 = new Label ();
				this.label5 = new Label ();
				this.tbUserName = new TextBox ();
				this.tbPassword = new TextBox ();
				this.tbPasswordConfirm = new TextBox ();
				this.cbRole = new ComboBox ();
				this.btThem = new Button ();
				this.btThoat = new Button ();
				base.SuspendLayout ();
				this.label1.Font = new System.Drawing.Font ("Verdana", 12F, FontStyle.Bold, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.label1.ForeColor = Color.MediumBlue;
				this.label1.Location = new Point (80, 16);
				this.label1.Name = "label1";
				this.label1.Size = new System.Drawing.Size (224, 23);
				this.label1.TabIndex = 0;
                this.label1.Text = "Thêm Người Truy Nhập";
				this.label2.Font = new System.Drawing.Font ("Verdana", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.label2.Location = new Point (24, 64);
				this.label2.Name = "label2";
				this.label2.Size = new System.Drawing.Size (136, 23);
				this.label2.TabIndex = 1;
                this.label2.Text = "Tên truy nhập:";
				this.label3.Font = new System.Drawing.Font ("Verdana", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.label3.Location = new Point (24, 88);
				this.label3.Name = "label3";
				this.label3.TabIndex = 2;
                this.label3.Text = "Mật khẩu:";
				this.label4.Font = new System.Drawing.Font ("Verdana", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.label4.Location = new Point (24, 112);
				this.label4.Name = "label4";
				this.label4.Size = new System.Drawing.Size (144, 23);
				this.label4.TabIndex = 3;
                this.label4.Text = "Xác nhận mật khẩu:";
				this.label5.Font = new System.Drawing.Font ("Verdana", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.label5.Location = new Point (24, 136);
				this.label5.Name = "label5";
				this.label5.Size = new System.Drawing.Size (128, 23);
				this.label5.TabIndex = 4;
                this.label5.Text = "Quyền truy nhập:";
				this.tbUserName.BorderStyle = BorderStyle.FixedSingle;
				this.tbUserName.Font = new System.Drawing.Font ("Verdana", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.tbUserName.Location = new Point (176, 64);
				this.tbUserName.Name = "tbUserName";
				this.tbUserName.Size = new System.Drawing.Size (152, 22);
				this.tbUserName.TabIndex = 5;
				this.tbUserName.Text = "";
				this.tbPassword.BorderStyle = BorderStyle.FixedSingle;
				this.tbPassword.Font = new System.Drawing.Font ("Verdana", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.tbPassword.Location = new Point (176, 88);
				this.tbPassword.Name = "tbPassword";
				this.tbPassword.PasswordChar = '\u002A';
				this.tbPassword.Size = new System.Drawing.Size (152, 22);
				this.tbPassword.TabIndex = 6;
				this.tbPassword.Text = "";
				this.tbPasswordConfirm.BorderStyle = BorderStyle.FixedSingle;
				this.tbPasswordConfirm.Font = new System.Drawing.Font ("Verdana", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.tbPasswordConfirm.Location = new Point (176, 112);
				this.tbPasswordConfirm.Name = "tbPasswordConfirm";
				this.tbPasswordConfirm.PasswordChar = '\u002A';
				this.tbPasswordConfirm.Size = new System.Drawing.Size (152, 22);
				this.tbPasswordConfirm.TabIndex = 7;
				this.tbPasswordConfirm.Text = "";
				this.cbRole.DropDownStyle = ComboBoxStyle.DropDownList;
				this.cbRole.Font = new System.Drawing.Font ("Verdana", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				theObjectArray = new object[4];
                theObjectArray[0] = "Trưởng Phòng Khám";
                theObjectArray[1] = "Bác Sĩ";
                theObjectArray[2] = "Y Tá";
                theObjectArray[3] = "Dược Sĩ";
				this.cbRole.Items.AddRange (theObjectArray);
				this.cbRole.Location = new Point (176, 136);
				this.cbRole.Name = "cbRole";
				this.cbRole.Size = new System.Drawing.Size (152, 22);
				this.cbRole.TabIndex = 8;
				this.btThem.FlatStyle = FlatStyle.Flat;
				this.btThem.Font = new System.Drawing.Font ("Verdana", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.btThem.Location = new Point (176, 176);
				this.btThem.Name = "btThem";
				this.btThem.Size = new System.Drawing.Size (72, 23);
				this.btThem.TabIndex = 9;
                this.btThem.Text = "Thêm";
				this.btThem.Click += new EventHandler (this.btThem_Click);
				this.btThoat.FlatStyle = FlatStyle.Flat;
				this.btThoat.Font = new System.Drawing.Font ("Verdana", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				this.btThoat.Location = new Point (256, 176);
				this.btThoat.Name = "btThoat";
				this.btThoat.Size = new System.Drawing.Size (72, 23);
				this.btThoat.TabIndex = 10;
                this.btThoat.Text = "Thoát";
				this.btThoat.Click += new EventHandler (this.btThoat_Click);
				this.AutoScaleBaseSize = new System.Drawing.Size (7, 16);
				base.ClientSize = new System.Drawing.Size (350, 211);
				theControlArray = new Control[11];
				theControlArray[0] = ((Control) this.btThoat);
				theControlArray[1] = ((Control) this.btThem);
				theControlArray[2] = ((Control) this.cbRole);
				theControlArray[3] = ((Control) this.tbPasswordConfirm);
				theControlArray[4] = ((Control) this.tbPassword);
				theControlArray[5] = ((Control) this.tbUserName);
				theControlArray[6] = ((Control) this.label5);
				theControlArray[7] = ((Control) this.label4);
				theControlArray[8] = ((Control) this.label3);
				theControlArray[9] = ((Control) this.label2);
				theControlArray[10] = ((Control) this.label1);
				base.Controls.AddRange (theControlArray);
				this.Font = new System.Drawing.Font ("Verdana", 9.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte) byte.MinValue));
				base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
				base.Icon = ((System.Drawing.Icon) theResourceManager.GetObject ("$this.Icon"));
				base.MaximizeBox = false;
				base.MinimizeBox = false;
				base.Name = "frmThemNguoiTruyNhap";
				base.StartPosition = FormStartPosition.CenterScreen;
                this.Text = "Thêm Người Truy Nhập";
				base.Load += new EventHandler (this.frmThemNguoiTruyNhap_Load);
				base.ResumeLayout (false);
				return;
			}
			
		#endregion
	}
	
}

